In a multiprocessing computing environment, more than one process may actively use the resources available in the computing environment. To avoid corruption of a resource due to the concurrent use or modification by multiple processes, a process may lock a resource and release the lock after the process has finished using the process.
Deadlock is a well-known problem in many programming environments. In some situations, a deadlock occurs when two processes or two elements (e.g., threads) in a process are each waiting for the other to release a lock, before either one can continue, which generates an infinite loop of waiting for both. Occurrence of a deadlock is often disruptive. Thus, software applications and multiprocessing environments, in which the applications operate, are typically tested to identify the causes of and program code updates needed to prevent deadlock. However, in practice, deadlock is generally difficult to predict or detect. The difficulty in deadlock prediction and detection is typically due to an inherently imperfect knowledge of synchronization within complex multi-threaded environments. Sometimes, acquiring multiple locks in a different order is deadlock-prone, while in other instances the acquisition order does not matter.